﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shifa
{
    class Clerkship
    {
        private string id;
        private string name;
        private string year;
        private List<Teacher> teachers;

        public Clerkship(string id, string name, string year)
        {
            this.id = id;
            this.name = name;
            this.year = year;
            this.teachers = new List<Teacher>();
        }

        public string Id
        {
            get { return this.id; }
        }

        public string Name
        {
            get { return this.name; }
        }

        public string Year
        {
            get { return this.year; }
        }

        public List<Teacher> Teachers
        {
            get { return this.teachers; }
            set { this.teachers = value; }
        }

        public void GetAverages(Question question, out double min_avg, out double max_avg)
        {
            min_avg = double.MaxValue;
            max_avg = double.MinValue;

            foreach (Teacher teacher in this.teachers)
            {
                foreach (Question q in teacher.Questions)
                {
                	if (q.CommentOnly) continue;
                	
                	if (q.Ratings.Count >= 5)
                	{
                		if (q.Equals(question))
	                    {
	                        double avg = q.GetAverage();
	                        
	                        if (avg < min_avg)
	                        {
	                            min_avg = avg;
	                        }
	
	                        if (avg > max_avg)
	                        {
	                            max_avg = avg;
	                        }
	                    }
                	}
                }
            }
        }

        public override string ToString()
        {
            return this.name + ", " + this.year;
        }
    }
}
